package cn.com.cetccst.illegalconnection;

import android.util.Log;

public class Logger {
    private static ILogger logger;

    public static void setILogger(ILogger logger) {
        Logger.logger = logger;
    }

    public static void log(String fmt, Object... args) {
        if (logger != null) {
            if (args != null && args.length > 0) {
                fmt = String.format(fmt, args);
            }
            logger.log(fmt);
        }
    }

    public static void log(Throwable throwable) {
        if (logger != null) {
            logger.log(Log.getStackTraceString(throwable));
        }
    }

    public static void log(String info, Throwable throwable) {
        if (logger != null) {
            logger.log(info + "\n" + Log.getStackTraceString(throwable));
        }
    }

    public interface ILogger {
        void log(String log);
    }
}
